package com.gudong.user.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gudong.model.result.AppResult;
import com.gudong.model.user.request.wx.WxFindRequest;
import com.gudong.model.user.request.wx.WxLoginRequest;
import com.gudong.user.entity.UserInfo;
import com.gudong.user.service.IUserInfoService;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author hl
 * @since 2025-03-05
 */
@RestController
@RequestMapping("/user/user-info")
@Slf4j
public class UserInfoController {

    @Resource
    private IUserInfoService userInfoService;
    ;

    @PostMapping("wxLogin")
    @Operation(summary = "微信登录")
    public AppResult<String> wxLogin(@RequestBody WxLoginRequest request) {
        String token = userInfoService.wxLogin(request);
        return AppResult.success(token);
    }

    @PostMapping("findUser")
    @Operation(summary = "用户查询")
    public AppResult<Page<UserInfo>> findUser(@RequestBody WxFindRequest request) {
        Page<UserInfo> userInfoPage = userInfoService.findUser(request);
        return AppResult.success(userInfoPage);
    }

}
